﻿using UnityEngine;
using System.Collections;

public class CameraManager : MonoBehaviour {

	public CameraData camData;
	public CameraDisplay camDis;

	public int setCamInd;

	void Awake()
	{
		camData = FindObjectOfType<CameraData> ();
		camDis = FindObjectOfType<CameraDisplay> ();
	}

	void OnMouseDown()
	{
		//print ("clicked");
		changeCamera (setCamInd);
	}

	public void changeCamera(int cameraIndex)
	{
		print ("zoomed");
		for(int i = 0; i< camDis.sceneCameras.Length; i++)
		{
			camData.setCameraIndex(cameraIndex);
			setCamInd = camData.getCameraIndex ();

			//print (camData.getCameraIndex());
			Camera mainCam = GameObject.FindWithTag("MainCamera").GetComponent<Camera>();
			if(i==cameraIndex)
			{
				mainCam.CopyFrom(camDis.sceneCameras[cameraIndex]);
				mainCam.enabled = true;
				print (mainCam.name);
				print(mainCam.transform.position);
				Camera.main.GetComponent<camerashake>().UpdateOriginalPos();
				PlayerPrefs.SetInt("curCam", cameraIndex);
			}
		}
	}
}
